<div ng-include="sys_html('app_develop/plugin/show_edit/'+pagedata.type)" onload="pagedata.start()"></div>
<div class="fe-save">
    <div class="fe-save-main">
        <div class="fe-save-info">
		<input type="text" style="height: 30px; width: 300px; border: 1px solid #bbb; border-radius: 3px; margin: 4px 10px; outline: none; padding-left: 10px;" placeholder="页面名称：输入页面名称" ng-model="pagedata.item.title"/>
		</div>
		<div class="fe-save-submit2" ng-click="post(pagedata.item,'design','look=1')">保存并预览</div>
        <div class="fe-save-submit save-submit" ng-click="post(pagedata.item,'design')">保存</div>
        <div class="fe-save-fold" onclick="fold()"></div>
        <div class="fe-save-gotop" onclick="$(document.body).animate({scrollTop:0},500)"><i class="fa fa-angle-up"></i><br>返回顶部</div>
    </div>
</div>
<div id="floating-content-choose"  class="modal fade"  tabindex="-1" style="z-index:2000;display:none">
    <div class="jinyun-modal-dialog modal-dialog" style='width: 920px;'>
        <div class="modal-content">
            <div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>选择字段</h3></div>
			<div class="modal-body form-horizontal">
				<ul class="nav nav-tabs" ng-show="!pagedata.choose_sun">
					<li ng-class="{'active':pagedata.current_fields==fields.fields}" ng-repeat="fields in pagedata.table_fields"><a href="javascript:;" ng-click="pagedata.current_fields=fields.fields">{{fields.title}}</a></li>
				</ul>
				<table class="table jinyun-table table-hover vertical-middle jinyun-form">
					<thead class="navbar-inner">
						<tr>
							<th class="text-left">字段标识</th>
							<th class="text-left">字段名</th>
							<th class="text-right" style="word-break : break-all;">操作</th>
						</tr>
					</thead>
						<tr ng-repeat="item in pagedata.current_fields">
							<td>{{item.name}}</td>
							<td>{{item.title}}</td>
							<td class="text-right">
								<a href="javascript:;" ng-click="pagedata.choose_result(item.data)" class="btn btn-primary">选取</a>
							</td>
						</tr>
				</table>
			</div>
            <div class="modal-footer"><a href="#" class="btn btn-primary" data-dismiss="modal" aria-hidden="true">完成</a></div>
        </div>
    </div>
</div>
<div id="floating-content-link"  class="modal fade"  tabindex="-1" style="z-index:2001;display:none">
    <div class="jinyun-modal-dialog modal-dialog" style='width: 920px;'>
        <div class="modal-content">
            <div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>选择跳转页面</h3></div>
			<div class="modal-body form-horizontal">
				
				<table class="table jinyun-table table-hover vertical-middle jinyun-form">
					<thead class="navbar-inner">
						<tr>
							<th class="text-left">页面标识</th>
							<th class="text-left">页面名称</th>
							<th class="text-right" style="word-break : break-all;">选择页面动作</th>
						</tr>
					</thead>
						<tr ng-repeat="item in pagedata.pages">
							<td>{{item.name}}</td>
							<td>{{item.title}}</td>
							<td class="text-right">
								<a href="javascript:;" ng-repeat="op in item.ops" ng-click="pagedata.link_result(op.url)" class="btn btn-primary">{{op.title}}</a>
							</td>
						</tr>
				</table>
			</div>
            
        </div>
    </div>
</div>
<div id="floating-content-op_edit"  class="modal fade"  tabindex="-1" style="z-index:2000;display:none">
    <div class="jinyun-modal-dialog modal-dialog" style='width: 920px;'>
        <div class="modal-content">
            <div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>设置动作</h3></div>
			<div class="modal-body form-horizontal">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label">动作标识</label>
					<div class="col-xs-12 col-sm-8 col-lg-9">
						<input type="text" class="form-control " ng-model="pagedata.op_edit.name"  />
						<div class="help-block">设置动作标识，只能由数字、字母、下划线组成</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label">动作名称</label>
					<div class="col-xs-12 col-sm-8 col-lg-9">
						<input type="text" class="form-control " ng-model="pagedata.op_edit.title"  />
						<div class="help-block">设置动作名称</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label">动作类型</label>
					<div class="col-xs-12 col-sm-8 col-lg-9">
						<div class="radio radio-inline" ng-repeat="(value,dtitle) in pagedata.extra_op_types">
							<label>
								<input type="radio" value="{{value}}" ng-model="pagedata.op_edit.type"/>{{dtitle}}
							</label>
						</div>
						<div class="help-block">选择动作类型</div>
					</div>
				</div>
				<div class="form-group" ng-show="pagedata.op_edit.type==7">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label">修改字段</label>
					<div class="col-xs-12 col-sm-8 col-lg-9">
						<select class="form-control" ng-model="pagedata.op_edit.field_name">
							<option value="" selected>请选择字段</option>
							<option ng-repeat="field in pagedata.table_fields[0].fields" ng-selected="pagedata.op_edit.field_name==field.name" value="{{field.name}}" >{{field.title}}</option>
						</select>
						<div class="help-block"></div>
					</div>
					
				</div>
				<div class="form-group" ng-show="pagedata.op_edit.type==7">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label">修改值</label>
					<div class="col-xs-12 col-sm-8 col-lg-9">
						<input type="text" class="form-control " ng-model="pagedata.op_edit.field_value"  />
						<div class="help-block">设置该动作修改将指定字段修改为何值，不填默认由前端传回</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label">成功后跳转</label>
					<div class="col-xs-12 col-sm-8 col-lg-9">
						<input type="text" class="form-control " ng-model="pagedata.op_edit.url"  />
						<div class="help-block">设置成功后跳转地址，不填则不跳转。支持系统标准url书写格式</div>
					</div>
				</div>
			</div>
            <div class="modal-footer"><a href="javascript:;" ng-click="pagedata.op_design_res()" class="btn btn-primary">确定</a></div>
        </div>
    </div>
</div>
<div id="floating-content-edit"  class="modal fade"  tabindex="-1" style="z-index:2000;display:none">
    <div class="jinyun-modal-dialog modal-dialog" style='width: 920px;'>
        <div class="modal-content">
            <div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>设置参数</h3></div>
			<div class="modal-body form-horizontal">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label">{{pagedata.edit_string.title}}</label>
					<div class="col-xs-12 col-sm-8 col-lg-9">
						<input type="text" class="form-control " ng-model="pagedata.edit_string.model"  />
						<div class="help-block">{{pagedata.edit_string.help}}</div>
					</div>
				</div>
				
			</div>
            <div class="modal-footer"><a href="javascript:;" ng-click="pagedata.edit_result()" class="btn btn-primary">确定</a></div>
        </div>
    </div>
</div>
<div id="floating-content-edit_tab"  class="modal fade"  tabindex="-1" style="z-index:2000;display:none">
    <div class="jinyun-modal-dialog modal-dialog" style='width: 920px;'>
        <div class="modal-content">
            <div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>设置导航参数</h3></div>
			<div class="modal-body form-horizontal">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label">导航名称</label>
					<div class="col-xs-12 col-sm-8 col-lg-9">
						<input type="text" class="form-control " ng-model="pagedata.current_tab.title"  />
						<div class="help-block"></div>
					</div>
				</div>
				
			
			<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label">链接地址</label>
					<div class="col-xs-12 col-sm-8 col-lg-9">
						<div class="input-group">
							<input type="text" class="form-control" placeholder="选择页面"  ng-model="pagedata.current_tab.url"/>
							<span class="input-group-btn">
								<button class="btn btn-primary" type="button" ng-click="pagedata.choose_url(pagedata.current_tab,'url')"><i class="fa fa-external-link"></i>选择页面</button>
							</span>
						</div>
						<div class="help-block"></div>
					</div>
			</div>
			</div>
            <div class="modal-footer"><a href="javascript:;" aria-hidden="true" data-dismiss="modal"  class="btn btn-primary">确定</a></div>
        </div>
    </div>
</div>
<script>
	
	function fold(){
        width= $(".fe-save").width();
        left = $(".fe-save").css("left");
        left = left.replace("px","");
        if(left>=0){
            $(".fe-save").animate({left:0-width+40+"px"},1000);
            $(".fe-save-fold").addClass("fe-save-fold2");
        }else{
            $(".fe-save").animate({left:"0px"},1000);
            $(".fe-save-fold").removeClass("fe-save-fold2");
        }
    }
	scope.pagedata.start=function(){
		$('.edit_class').mouseover(function(){
			$(this).addClass('diy-edit-group');
		});
		$('.edit_class').mouseleave(function(){
			$(this).removeClass('diy-edit-group');
		});
	}
	scope.pagedata.modal=function(type){
		window.bootstrap('#floating-content-'+type).modal();
	}
	scope.pagedata.edit_tab=function(tab){
		scope.pagedata.current_tab=tab;
		window.bootstrap('#floating-content-edit_tab').modal();
	}
	scope.pagedata.edit=function(value,field,title,help){
		scope.pagedata.edit_string={};
		scope.pagedata.edit_string.value=value;
		scope.pagedata.edit_string.field=field;
		scope.pagedata.edit_string.model=value[field];
		scope.pagedata.edit_string.title=title;
		scope.pagedata.edit_string.help=help;
		window.bootstrap('#floating-content-edit').modal();
	}
	scope.pagedata.edit_result=function(){
		scope.pagedata.edit_string.value[scope.pagedata.edit_string.field]=scope.pagedata.edit_string.model;
		window.bootstrap('#floating-content-edit').modal('hide');
	}
	scope.pagedata.choose_field=function(obj,field,father){
		scope.pagedata.choose_current_obj=obj;
		scope.pagedata.choose_current_field=field;
		if(father){
			scope.pagedata.choose_sun=true;
			scope.pagedata.current_fields=scope.pagedata.sun_tables[father].fields;
		}else{
			scope.pagedata.choose_sun=false;
			scope.pagedata.current_fields=scope.pagedata.table_fields[0].fields;
		}
		
		window.bootstrap('#floating-content-choose').modal();
	}
	scope.pagedata.choose_result=function(data){
		scope.pagedata.choose_current_obj[scope.pagedata.choose_current_field]=data;
		window.bootstrap('#floating-content-choose').modal('hide');
	}
	scope.pagedata.showhtml=function(name){
		if(!name){
			return false;
		}
		return scope.sys_html('app_develop/plugin/show/'+name);
	}
	scope.pagedata.op_design=function(value,field,op_name){
		scope.pagedata.current_opvalue=value;
		scope.pagedata.current_opfield=field;
		if(!scope.pagedata.item.design.ops){
			scope.pagedata.item.design.ops={};
		}
		if(op_name && scope.pagedata.item.design.ops[op_name]){
			scope.pagedata.edit_op=scope.pagedata.item.design.ops[op_name];
		}else{
			scope.pagedata.edit_op={};
		}
		window.bootstrap('#floating-content-op_edit').modal();
	}
	scope.pagedata.op_design_res=function(){
		if(!scope.pagedata.edit_op.name){
			alert('请输入标识');return false;
		}
		var key='$('+scope.pagedata.edit_op.name+')';
		scope.pagedata.item.design.ops[key]=scope.pagedata.edit_op;
		scope.pagedata.current_opvalue[scope.pagedata.current_opfield]=key;
		window.bootstrap('#floating-content-op_edit').modal('hide');
	}
	window.scope.pagedata.choose_url=function(value,field){
		scope.pagedata.current_opvalue=value;
		scope.pagedata.current_opfield=field;
		window.bootstrap('#floating-content-link').modal();
	}
	window.scope.pagedata.link_result=function(res){
		scope.pagedata.current_opvalue[scope.pagedata.current_opfield]=res;
		window.bootstrap('#floating-content-link').modal('hide');
	}
</script>